
import * as type from './mutation-types'
export const state = {
    status: -9999,
    errmsg: '',


    checkDayList: [],
    dayListData: {},
    osListData: {},
    mediaListData: {},
    mediaSearchList: [],
    geoListData: {},
    geoSearchList: [],

    seriesListData: {},
    groupListData: {},
    mainListData: {},
    seriesByGeoListData: {},
    groupByGeoListData: {},
    mainByGeoListData: {},
    seriesSearchList: [],
    groupSearchList: [],
    mainSearchList: [],
    // 从新设置表格内容
    tableData: [],
    tableTotal: 0,
    // 广告平台下载
    downloadData: {},
    downloadStatus: '',
    // 获取表格合计数据
    totalData: {},
    getTotalDatastatus: '',

    channelListData: {},
    channelSearchList: [],
    channelCampaignSearchList: [],
    channelAdgroupSearchList:[],
    channelAdSearchList: [],
}

export const mutations = {
    // 初始化内容
    [type.RESET_STATE_ITEM](state, res) {
        for (const key in res) {
            state[key] = res[key]
        }
    },
    // 设置state数值
    [type.SET_DAY_LIST](state, res) {
        if (res && res.code == 0) {
            state.dayListData = res?.content || {}
        }
    },
    // 设置state数值
    [type.SET_OS_LIST](state, res) {
        if (res && res.code == 0) {
            state.osListData = res?.content || {}
        }
    },
    // 设置state数值
    [type.SET_MEDIA_LIST](state, res) {
        if (res && res.code == 0) {
            state.mediaListData = res?.content || {}
        }
    },
    // 设置state数值
    [type.SET_MEDIA_SEARCH_LIST](state, res) {
        if (res && res.code == 0) {
            state.mediaSearchList = res?.content?.mediaList || []
        }
    },

    // 设置state数值
    [type.SET_GEO_LIST](state, res) {
        if (res && res.code == 0) {
            state.geoListData = res?.content || {}
        }
    },
    // 设置state数值
    [type.SET_GEO_SEARCH_LIST](state, res) {
        if (res && res.code == 0) {
            state.geoSearchList = res?.content?.geoList || []
        }
    },

    [type.SET_SERIES_LIST](state, res) {
        if (res && res.code == 0) {
            state.seriesListData = res?.content || {}
        }
    },
    [type.SET_GROUP_LIST](state, res) {
        if (res && res.code == 0) {
            state.groupListData = res?.content || {}
        }
    },
    [type.SET_MAIN_LIST](state, res) {
        if (res && res.code == 0) {
            state.mainListData = res?.content || {}
        }
    },
    [type.SET_SERIES_BY_GEO_LIST](state, res) {
        if (res && res.code == 0) {
            state.seriesByGeoListData = res?.content || {}
        }
    },

    [type.SET_GROUP_BY_GEO_LIST](state, res) {
        if (res && res.code == 0) {
            state.groupByGeoListData = res?.content || {}
        }
    },
    [type.SET_MAIN_BY_GEO_LIST](state, res) {
        if (res && res.code == 0) {
            state.mainByGeoListData = res?.content || {}
        }
    },


    [type.SET_SERIES_SEARCH_LIST](state, res) {
        if (res && res.code == 0) {
            state.seriesSearchList = res?.content?.campaignList || []
        }
    },


    [type.SET_GROUP_SEARCH_LIST](state, res) {                
        if (res && res.code == 0) {
            state.groupSearchList = res?.content?.adgroupList || []
        }
        // console.log(state.groupSearchList, 11);
        
    },


    [type.SET_MAIN_SEARCH_LIST](state, res) {
        if (res && res.code == 0) {
            state.mainSearchList = res?.content?.adList || []
        }
    },

    // 下载的数据
    [type.DOWNLOAD_DATA_RECEIVE](state, res) {
        state.downloadData = res
    },

    [type.SET_CHANNEL_LIST](state, res) {
        if (res && res.code == 0) {
            state.channelListData = res?.content || {}
        }
    },
    [type.SET_CHANNEL_SEARCH_LIST](state, res) {
        if (res && res.code == 0) {
            state.channelSearchList = res?.content?.mediaList || []
        }
    },
    [type.SET_CHANNEL_CAMPAIGN_SEARCH_LIST](state, res) {
        if (res && res.code == 0) {
            state.channelCampaignSearchList = res?.content?.campaignList || []
        }
    },
    [type.SET_CHANNEL_ADGROUP_SEARCH_LIST](state, res) {
        if (res && res.code == 0) {
            state.channelAdgroupSearchList = res?.content?.adgroupList || []
        }
    },
    [type.SET_CHANNEL_AD_SEARCH_LIST](state, res) {
        if (res && res.code == 0) {
            state.channelAdSearchList = res?.content?.adList || []
        }
    },


    // 获取合计行数据
    [type. GET_TOTAL_DATA] (state, res) {        
        if (res && res.code == 0) {
            state.totalData = res?.content || {}
        }
    }
}
